﻿namespace ConsoleApp9
{

    class EventArgs
    {
        public int attack = 0;
        public bool poisoned = false;
    }

    class Enemy
    {
        private int blood = 100;
        public void MinusBlood(object o, EventArgs args)
        {
            Console.WriteLine("好痛！我是Enemy");
            blood -= args.attack;

            //中毒
            if(args.poisoned )
            {
                Console.WriteLine( "Enemy 中毒！");
            }

            Player player = (Player)o;
            player.Shout();
        }
    }

    class NPC
    {
        private int blood = 100;
        public void BeAttackedTest(object o, EventArgs args)
        {
            Console.WriteLine("好痛！我是NPC");
            blood -= args.attack;
        }
    }
    class Player
    {
        public delegate void OnAttackDelegate(object o, EventArgs args);
        public OnAttackDelegate OnAttack = null;

        public void DoAOE()
        {

            if (OnAttack != null)
            {
                EventArgs args = new EventArgs();
                args.attack = 10;
                args.poisoned = true;
                OnAttack(this, args);
            }
        }
        public void Shout()
        {
            Console.WriteLine("Player 好痛");
        }
    }





    internal class Program
    {
        static void Main(string[] args)
        {
            Player player = new Player();
            
            Enemy e1 = new Enemy();
            Enemy e2 = new Enemy();
            Enemy e3 = new Enemy();

            NPC npc = new NPC();

            player.OnAttack += e1.MinusBlood;
            player.OnAttack += e2.MinusBlood;
            player.OnAttack += e3.MinusBlood;
            player.OnAttack += npc.BeAttackedTest;

            player.DoAOE();

        }
    }
}